package com.hudilao.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hudilao.entity.Setmeal;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface SetmealMapper extends BaseMapper<Setmeal> {


    //查询关联当前菜品的所有套餐
    @Select("SELECT * FROM setmeal WHERE id IN (SELECT setmeal_id FROM setmeal_dish WHERE dish_id = #{dishId})")
    List<Setmeal> findByDishId(Long dishId);

    //更新套餐状态
    @Update("UPDATE setmeal SET status = #{status} WHERE id = #{id}")
    int updateStatusById(Setmeal setmeal);
}
